package com.qianfeng.chainmobile.api.service.impl;

import com.qianfeng.chainmobile.api.service.SendMsg2MqService;
import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SendMsg2MqServiceImpl implements SendMsg2MqService {

    private RabbitTemplate rabbitTemplate;
    @Autowired
    public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public void sendMessage(List<Standard_Submit> standard_submitList) {
        System.err.println("开始发送数据");
        standard_submitList.forEach(standard_submit -> rabbitTemplate.convertAndSend(RabbitMqConsants.TOPIC_PRE_SEND,standard_submit));
    }
}
